Skip to content

feat(web): allow free-model sessions on zero balance and unify access…#4367

Open
wombatepiclandingstudio wants to merge 4 commits into
Kilo-Org:mainfrom
wombatepiclandingstudio:allow-sessions-with-free-models-on-zero-balance
Open

feat(web): allow free-model sessions on zero balance and unify access…#4367
wombatepiclandingstudio wants to merge 4 commits into
Kilo-Org:mainfrom
wombatepiclandingstudio:allow-sessions-with-free-models-on-zero-balance

Conversation

@wombatepiclandingstudio

Copy link
Copy Markdown

…-level eligibility

Combine five related changes that mirror AppBuilder behavior in Cloud Agent Next and extract a shared helper for the balance-threshold access level shape used by three routers.

  • Cloud Agent Next: allow users with no balance to create sessions against free models. NewSessionPanel hides the blocking banner and filters to free / BYOK-capable models when accessLevel is 'limited'; the personal and organization prepareSession routers route free or BYOK-capable models through the shared AppBuilder client so the worker skips the $1 minimum balance check. Paid models continue to require the minimum.
  • Introduce apps/web/src/lib/access-level-eligibility.ts with a generic buildAccessLevelEligibility helper. cloud-agent-next-eligibility.ts is now a thin wrapper that preserves its type aliases and constant; app-builder-router.ts and organization-app-builder-router.ts delegate to the shared helper with MIN_BALANCE_FOR_APP_BUILDER. No public/tRPC type changes.
  • Extract server-side eligibility into computeCloudAgentNextBalanceCheckEligibility so the routers consult the user's enabled BYOK providers (or the org's) alongside isFreeModel, closing the gap where a zero-balance user picking a BYOK-capable paid model still hit the worker minimum.

Tests cover free / BYOK / paid gating on both routers, the accessLevel branches, and the new helper.

Summary

Verification

  • [ ]

Visual Changes

Before After

Reviewer Notes

…-level eligibility

Combine five related changes that mirror AppBuilder behavior in Cloud Agent
Next and extract a shared helper for the balance-threshold access level
shape used by three routers.

- Cloud Agent Next: allow users with no balance to create sessions against
  free models. NewSessionPanel hides the blocking banner and filters to
  free / BYOK-capable models when accessLevel is 'limited'; the personal
  and organization prepareSession routers route free or BYOK-capable
  models through the shared AppBuilder client so the worker skips the
  $1 minimum balance check. Paid models continue to require the minimum.
- Introduce apps/web/src/lib/access-level-eligibility.ts with a generic
  buildAccessLevelEligibility helper. cloud-agent-next-eligibility.ts is
  now a thin wrapper that preserves its type aliases and constant;
  app-builder-router.ts and organization-app-builder-router.ts delegate
  to the shared helper with MIN_BALANCE_FOR_APP_BUILDER. No public/tRPC
  type changes.
- Extract server-side eligibility into
  computeCloudAgentNextBalanceCheckEligibility so the routers consult the
  user's enabled BYOK providers (or the org's) alongside isFreeModel,
  closing the gap where a zero-balance user picking a BYOK-capable paid
  model still hit the worker minimum.

Tests cover free / BYOK / paid gating on both routers, the accessLevel
branches, and the new helper.
: personalEligibilityQuery.isPending;
const hasInsufficientBalance =
!isEligibilityLoading && eligibilityData && !eligibilityData.isEligible;
const hasLimitedAccess = !isEligibilityLoading && eligibilityData?.accessLevel === 'limited';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: isFormValid still blocks submission for limited-access users, defeating this PR's goal

Further down in this component, isFormValid requires !hasInsufficientBalance, and hasInsufficientBalance is true whenever eligibilityData.isEligible is false — which is exactly the case whenever accessLevel is 'limited' (i.e. whenever hasLimitedAccess here is true). So for every zero/low-balance user, the submit button (disabled={!isFormValid || ...}) and the Cmd/Ctrl+Enter shortcut stay disabled even after they pick a free or BYOK-capable model from the filtered modelOptions. The stated purpose of this PR — letting zero-balance users start Cloud Agent sessions on free models — can't actually be exercised from this UI as written. isFormValid needs to permit submission when hasLimitedAccess is true and the selected model is free/BYOK-capable, mirroring the filter already applied to modelOptions.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The previously flagged CRITICAL issue is fixed: isFormValid now allows submission for limited-access users when the selected model is free or BYOK-capable, matching the model-list filter.

Files Reviewed (1 file)
  • apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx
Previous Review Summary (commit 9e37184)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 9e37184)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The new hasLimitedAccess gating in NewSessionPanel.tsx filters the model list correctly, but isFormValid was never updated to allow submission for limited-access users, so the feature this PR adds (letting zero-balance users start sessions on free/BYOK models) can't be triggered from the UI.

Overview

Severity Count
CRITICAL 1
WARNING 0
SUGGESTION 0
Issue Details (click to expand)

CRITICAL

File Line Issue
apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx 165 isFormValid still requires !hasInsufficientBalance, which is true whenever accessLevel is 'limited', so the submit button/keyboard shortcut stay disabled for zero-balance users even after selecting a free/BYOK model
Files Reviewed (13 files)
  • apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx - 1 issue
  • apps/web/src/lib/access-level-eligibility.ts
  • apps/web/src/lib/cloud-agent-next/balance-check-eligibility.ts
  • apps/web/src/lib/cloud-agent-next/balance-check-eligibility.test.ts
  • apps/web/src/lib/cloud-agent-next/cloud-agent-client.ts
  • apps/web/src/lib/cloud-agent-next/cloud-agent-client.test.ts
  • apps/web/src/routers/app-builder-router.ts
  • apps/web/src/routers/cloud-agent-next-eligibility.ts
  • apps/web/src/routers/cloud-agent-next-router.ts
  • apps/web/src/routers/cloud-agent-next-router.test.ts
  • apps/web/src/routers/organizations/organization-app-builder-router.ts
  • apps/web/src/routers/organizations/organization-cloud-agent-next-router.ts
  • apps/web/src/routers/organizations/organization-cloud-agent-next-router.test.ts

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5-20260630 · Input: 30 · Output: 8K · Cached: 682.4K

Review guidance: REVIEW.md from base branch main

wombatepiclandingstudio and others added 3 commits July 2, 2026 16:18
…gent users

isFormValid still gated submission on !hasInsufficientBalance, which is true
for every accessLevel: 'limited' user. The submit button (and Cmd/Ctrl+Enter
shortcut) stayed disabled even after such a user picked a free or
BYOK-capable model from the already-filtered picker.

Mirror the picker's isFree || hasUserByokAvailable filter in isFormValid so
the UI matches what the server (computeCloudAgentNextBalanceCheckEligibility
+ x-skip-balance-check) already permits. Paid models selected via stale state
or agent override remain blocked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant